<?php

class BDealcallbackCoupons extends UWorkletBehavior {

	public function columns()
	{
		return array(
			array(
				'header' => '',
				'type' => 'image',
				'value' => '$data->imageBin?app()->storage->bin($data->imageBin)->getFileUrl("original"):null',
			),
			array(
				'header' => $this->t('Name'),
				'name' => 'name',
				'value' => 'wm()->get("dealcallback.coupons")->render("coupons",array(
					"deal"=>$data,
					"dealcallback"=>MDealcallback::model()->findByPk($data->id)))',
			),
			array(
				'name' => $this->t('Purchase Date'),
				'value' => 'app()->getDateFormatter()->formatDateTime(
					utime($data->getOrderDate($data->getAllCoupons(app()->user->id,'
					. var_export($this->getOwner()->model->hasUsed,true).'),false)), "medium", false)',
			),
			array(
				'name' => $this->t('Expiration Date'),
				'value' => '$data->expire
					? app()->getDateFormatter()->formatDateTime(
						utime($data->expire,false), "medium", false)
					: "'.$this->t('Never').'"',
			),
		);
	}

//	public function afterConfig() {
//		$this->getOwner()->insertAfter('limitPerUser', $this->properties());
//	}
	
	public function beforeGetColumns()
	{
		return $this->columns();
	}
}